
One of the things that is a must have for me, when it comes to cell phones and using them, is the ability to print something from my phone. People will email me something, or send me a file in a message that I need to print while I am not at my computer. Sometimes this happens at church, where I need to print off a few more coloring pages for the kids Sunday school class, or at work, where an invoice came in an email and I need to physically put a printed copy into a shipping box.
Either way, Ubuntu Touch seems to be lacking in the printing department. While all of Linux seems to use CUPS, Ubuntu Touch doesn't seem to have it. On Xenial, there was an app called SimplePrint[1], where you could use the IPP protocol to print from your phone, but it got "left behind" when UT moved to Focal. I was able to work with the original developer and help rebuild it for Focal, and that was my go to printing app. Unfortunately, when UT upgraded from Focal to Noble, SimplePrint quit working. It still would load up and connect to the printer, but would print blank pages, which was not very useful.
In case you are asking youself: What is IPP? IPP is the Internet Printing Protocol, which allows you to simply 'send' compatible files to a modern printer, and it will print what it receives. This means there is no processing anything to some sort of post script and sending that to the printer. Instead, you query the printer to ask what file formats are acceptable, such as PDF and JPG (the most commonly accepted formats), and then you send it a file of that type, and it prints whichever compatible file it receives by this protocol.
Originally, I tried to help update SimplePrint from Focal to Noble, but there were a lot of dependencies that were really written based on Xenial and I was not smart enough to overcome the obstacles and make it work in Noble. SimplePrint is also written in Go, and I have no Go programming knowledge, so every turn of trying to upgrade it just didn't work, because I lacked the knowledge to understand the issues.
But, I still need a printing option from my phone. So a week ago, I decided to make a new IPP printing app based on C and python, instead of on Go. At first I forked SimplePrint, and was trying to keep it the same, just with C instead of Go under the hood, but I ended up gutting all but a portion of the GUI.
It was a long seven days, mostly due to my lack of knowledge and feeble programming skills. I actually know a little Java, a little C++, but not really any C or Python, so this was all new to me. The hardest part, though, was the QML, which I am unfamiliar with. Lacking any sort of IDE so you can "see" what you are building (there are some QML IDE's but none that support UT because you need the Lomori libraries in it), I really struggled with trying to make it functional and look nice. You can check out my butchered job here:
https://gitlab.com/alaskalinuxuser/ipprint
An early hurdle for me was actually inline building the C files into a program that I could use, because I needed it to build for the appropriate architecture. I have never made CMake files before, and that was a must for this project. I was borrowing the C program from an IPP-example MIT licensed repository[2]. The original repo had this make file:
#
# 'make all' - Compile all source file to generate executables
# 'make clean' - Clean executables
#
# Compilation settings
CC = gcc
CFLAGS = -g -Wall
LDLIBS = -lcups
# targets to build
TARGETS = get-printer-attributes print-job
all: $(TARGETS)
.PHONY: clean
# clean executables
clean:
$(RM) $(TARGETS)
But I needed to figure out how to build it with CMake. It ended up being a lot simpler than I thought, but most CMake files look so daunting. Here is the CMakeLists.txt file for the print-job binary:
cmake_minimum_required(VERSION 3.3)
# The name of what I'm building.
project(print-job)
# The name of the executable and the c/h files to build it.
add_executable(print-job print-job.c types.h)
# The libraries to link into the project.
target_link_libraries(print-job PRIVATE cups)
The key point that I learned was the linking of the library. I needed that lcups library from the makefile, and I was able to add it with the target_link_libraries(print-job PRIVATE cups) line in the CMakeLists.txt file. But, praise God, it worked, and now I have a working printing application on my Noble UT phone again.
Linux - keep it simple.
[1] SimplePrint [2] IPP-example